/**
 * Created by 鄢鹏权 on 2017/04/08.
 */
///<reference path="Config.ts"/>
///<reference path="Menu.ts"/>

namespace Avalon{
    export class Index extends Avalon.VM{
        $id='index';
        head={};
        Header={
            Title:''
        };
        ModalConfig={
            Show:false,
            Html:'',
            Title:'',
            OnSuccess:function(){},
            OnClose:function(){},
        };
        headHtml="";
        contentHtml="";
        footHtml="";
        Control={
            ShowNav:true,
            ShowMenu:true,
            ShowMessage:false,
            ShowNotification:false,
            ShowTask:false
        };
        messages=[
            // {
            //     Title:'通知',
            //     Content:'警告',
            //     Time:'5 m',
            //     Src:'dist/img/user2-160x160.jpg',
            //     Alt:'警告'
            // }
            ];
        notifications=[
            // {
            //     Class:'fa-users text-aqua',
            //     Content:'我勒个去'
            // }
            ];
        tasks=[
            // {
            //     Title:'任务1',
            //     Percent:20,
            //     Style:'width:20%;'
            // }
            ];
        login=false;//是否登录
        user={
            Src:'//cdn.bootcss.com/admin-lte/2.3.11/img/user2-160x160.jpg',
            Name:'',
            Memo:'',
            Small:'',
            UN:'',
            UID:'',
            Status:{
                Text:'',
            },
            Menus:[
                {
                    Title:'离开',
                    Href:'out'
                }
                ],
            Groups:[0],
            Sex:''
        };
        loginInput={
            Account:"",
            PWD:""
        };
        nav:{};
        loginFn=function () {
            Config.loginFn();
        };
        logoutFn=function () {
            Config.logoutFn();
        };
        menu=[];
        ready(n,p?){
            Config.ready();
            Avalon.Router.ready();
        }
    }
}
let index = avalon.define(new Avalon.Index());
index.$watch('user.UID',function (n,o) {
     if(Number(n)>0){
        Config.login();
     }else{
        Config.logout();
     }
});
avalon.ready(function () {
    index.menu=clone(Menu.Menu.menu);
    index.ready();
    avalon.scan(document.getElementsByTagName('html')[0])
});